<?php
include_once("../includes/page_utf_class.php");
include_once("../module/product/includes/plugin_order_class.php");
include("../lang/cn/company_type_config.php");
$order = new order;
//=======================
if(isset($_GET['orderid'])&&is_numeric($_GET['orderid']))
{
	$order->set_order_statu($_GET['orderid'],4,$_SESSION['ADMIN_USER']);
	msg("module.php?m=product&s=order.php");
}
if($_GET['code'])
{
	$str=" and  a.order_id='$_GET[code]' ";	
}
if($_GET['userid'] && $_GET['userid']){
    $str.= " and a.member_id={$_GET['userid']} ";
}
/*
 * 判断不是admin管理员账号登录 就只能获取当前登录账号的数据
 */
if($_SESSION['ADMIN_USER']=='admin'){
	$sql="select a.*,(cost+freight+tax_price+insurance_fee-cpns_price-discount) as sum,(select username from ".MEMBER." where userid=a.member_id) user from ".ORDER." a where status=1 $str order by id desc";
}else{
	$user = $_SESSION['ADMIN_USER'];
	$asql = "select * from haiou_admin where user='$user'";
	$db->query($asql);
	$info = $db->fetchRow();
	$group_id = $info['group_id']; //分组id
	$asql = "select * from haiou_admin_group where group_id='$group_id'";
	$db->query($asql);
	$group_info = $db->fetchRow();
	if($group_info['group_name']=='商家'){
		$seller_id = $info['id'];
		$sql="select a.*,(cost+freight+tax_price+insurance_fee-cpns_price-discount) as sum,(select username from ".MEMBER." where userid=a.member_id) user from ".ORDER." a where a.seller_id=$seller_id and status=1 $str order by id desc";
	}else{
		$sql="select a.*,(cost+freight+tax_price+insurance_fee-cpns_price-discount) as sum,(select username from ".MEMBER." where userid=a.member_id) user from ".ORDER." a where status=1 $str order by id desc";
	}
}
//=============================
$page = new Page;
$page->listRows=20;
if (!$page->__get('totalRows')){
	$db->query($sql);
	$de['count']=$page->totalRows = $db->num_rows();
}
$de['count']=$de['count']?$de['count']:$_GET['totalRows'];
$sql .= "  limit ".$page->firstRow.",".$page->listRows;
$de['page'] = $page->prompt();
//=============================
$db->query($sql);
$ss=$db->getRows();
foreach($ss as $k)
{
	$k['order_pay_status']=$order_pay_status[$k['status']-1];
	$list[]=$k;
}
$de["list"]=$list;
$tpl->assign("order_shop_status",$order_shop_status);
$tpl->assign("de",$de);
$tpl->assign("config",$config);
$tpl->display("order_payment.htm");

?>